<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class C_public_function extends CI_Controller {
	function C_public_function(){
		parent::__construct();
		
		checkLogin();
	}
	
	function get_div(){
		$query = isset($_POST['query']) ? @$_POST['query'] : "";
		$result=$this->m_public_function->get_div($query);
		echo $result;
	}
	
	function get_branch(){
		$query = isset($_POST['query']) ? @$_POST['query'] : "";
		$result=$this->m_public_function->get_branch($query);
		echo $result;
	}
	
	function get_procurement(){
		$query = isset($_POST['query']) ? @$_POST['query'] : "";
		$result=$this->m_public_function->get_procurement($query);
		echo $result;
	}
	
	function get_payment(){
		$query = isset($_POST['query']) ? @$_POST['query'] : "";
		$result=$this->m_public_function->get_payment($query);
		echo $result;
	}
	
	function get_project(){
		$query = isset($_POST['query']) ? @$_POST['query'] : "";
		$m_branch=@$_POST["branch_id"];
		$m_branch=is_numeric($m_branch)?$m_branch:0;
		$result=$this->m_public_function->get_project($query, $m_branch);
		echo $result;
	}
	
	function get_job(){
		$div_id=@$_POST["div_id"];
		$div_id=is_numeric($div_id)?$div_id:0;
		$query = isset($_POST['query']) ? @$_POST['query'] : "";
		
		$result=$this->m_public_function->get_job($query, $div_id);
		echo $result;
	}
	
	function get_job_bybranchproject(){
		$branch=@$_POST["branch_id"];
		$branch=is_numeric($branch)?$branch:0;
		$project=@$_POST["project_id"];
		$project=is_numeric($project)?$project:0;
		$result=$this->m_public_function->get_job_bybranchproject($branch, $project);
		echo $result;
	}
	
	function get_job_bybranchprojectBelumMenang(){
		$branch=@$_POST["branch_id"];
		$branch=is_numeric($branch)?$branch:0;
		$project=@$_POST["project_id"];
		$project=is_numeric($project)?$project:0;
		$result=$this->m_public_function->get_job_bybranchprojectBelumMenang($branch, $project);
		echo $result;
	}
	
	function get_jobdet_all(){
		$query = isset($_POST['query']) ? @$_POST['query'] : "";
		$start = (integer) (isset($_POST['start']) ? @$_POST['start'] : @$_GET['start']);
		$end = (integer) (isset($_POST['limit']) ? @$_POST['limit'] : @$_GET['limit']);
		$task = isset($_POST['task']) ? @$_POST['task'] : "";
		$master_id = isset($_POST['master_id']) ? @$_POST['master_id'] : "";
		
		$selected_id=@$_POST["selected_id"];
		$selected_id = json_decode($selected_id);
		
		$result=$this->m_public_function->get_jobdet_all($task,$master_id,$selected_id,$query,$start,$end);
		echo $result;
	}
	
	function get_vendor(){
		$query = isset($_POST['query']) ? @$_POST['query'] : "";
		$vendor_type=@$_POST["vendor_type"];
		$start = (integer) (isset($_POST['start']) ? @$_POST['start'] : @$_GET['start']);
		$end = (integer) (isset($_POST['limit']) ? @$_POST['limit'] : @$_GET['limit']);
		$result=$this->m_public_function->get_vendor($query, $vendor_type, $start, $end);
		echo $result;
	}
	
	function get_komp_byfilter(){
		$branch=@$_POST["branch_id"];
		$branch=is_numeric($branch)?$branch:0;
		$project=@$_POST["project_id"];
		$project=is_numeric($project)?$project:0;
		$job=@$_POST["job_id"];
		$job=is_numeric($job)?$job:0;
		
		$result=$this->m_public_function->get_komp_byfilter($branch, $project, $job);
		echo $result;
	}
	
	function get_unit(){
		$query = isset($_POST['query']) ? @$_POST['query'] : "";
		$result=$this->m_public_function->get_unit($query);
		echo $result;
	}
	
	function get_kontrak(){
		$query = isset($_POST['query']) ? @$_POST['query'] : "";
		$start = (integer) (isset($_POST['start']) ? @$_POST['start'] : @$_GET['start']);
		$end = (integer) (isset($_POST['limit']) ? @$_POST['limit'] : @$_GET['limit']);
	
		$branch_id = (integer) (isset($_POST['branch_id']) ? @$_POST['branch_id'] : @$_GET['branch_id']);
		$project_id = (integer) (isset($_POST['project_id']) ? @$_POST['project_id'] : @$_GET['project_id']);
	
		$result=$this->m_public_function->get_kontrak($query, $start, $end, $branch_id, $project_id);
		echo $result;
	}
	function get_ppn(){
		$result=$this->m_public_function->get_ppn();
		echo '({"total":"1", "results":[{"setup_ppn":"' . $result . '"}]})';
	}
	
	function test_dynamiccolumns(){
		echo "{
        metaData: {
                fields: [
                        {header: 'Name', name: 'name', sortable: true},
                        {header: 'Size', name: 'size'},
                        {header: 'Last Modified', name: 'lastmod'}
                ],
                root: 'rows'
        },
        rows: [
                {name: 'Image one', size:46.5, lastmod: new Date(2007, 10, 29)},
                {name: 'Image Two', size:43.2, lastmod: new Date(2007, 10, 30)}
        ],
        success: true
}";
	}
	
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */